
package com.cse210.grocerwe.server;

import org.restlet.resource.ServerResource;
import com.cse210.grocerwe.common.*;
import com.cse210.grocerwe.client.*;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import org.restlet.resource.Put;

public class APIResourceE extends ServerResource implements
APIInterfaceE
{
	PersistenceManager pm;
	
    
    @Put
    public void leaveGroup(String groupKey, String user)
    {
    	pm = PMF.get().getPersistenceManager();
    	Query q = pm.newQuery(MapUserToGroup.class);
		q.setFilter("user == x && group == y");
		q.declareParameters("String x, String y"); 
		q.deletePersistentAll(user.toLowerCase(),groupKey);
		
		/*
		 * DELETE ITEMS FROM THIS USER
		 */
		pm.close();
    }
    	
}
